const Router = require('koa-router')
const RegistrationsController = require('../controllers/registration.controller')
const jwt = require('../middlewares/jwt.middleware')
const isRole = require('../middlewares/role.middleware')

const router = new Router()
const registrationsController = new RegistrationsController()
router.prefix('/api/registrations')

router.get('/', jwt, registrationsController.findAll)

router.get('/:id', jwt, registrationsController.findOne)

router.post('/', jwt, registrationsController.addOne)

router.patch('/:id', jwt, registrationsController.updateOne)

router.delete('/:id', jwt, registrationsController.deleteOne)

router.patch('/:id/resolve', jwt, isRole(['admin', 'auditor']), registrationsController.resolve)

router.patch('/:id/reject', jwt, isRole(['admin', 'auditor']), registrationsController.reject)

module.exports = router